import 'package:http/http.dart' as http;
import 'package:http/http.dart';

import 'dart:convert';


class HomepageHttp{

  static String apiurl = "http://a.itying.com/api/productlist";
  static String apiurllogin = "http://a.itying.com/api/dologin";
  //获取数据
  static Future getdata() async {
    Response  response = await http.get(apiurl);
    if(response.statusCode == 200){
      print(response.body is String);
      //JSON 子符串
      print(json.decode(response.body));
      return json.decode(response.body);
    }else{
      print("Request failed with status: ${response.statusCode}.");
      return "失败";
    }
  }
  //提交数据
  static Future postData(Map postdate) async{
    Response  response = await http.post(apiurllogin,body: postdate);
     if(response.statusCode == 200){
      print(response.body is String);
      //JSON 子符串
      print(json.decode(response.body));
      return json.decode(response.body);
    }else{
      print("Request failed with status: ${response.statusCode}.");
      return "失败";
    }
  }
}
